/* COPYRIGHT_CHUNFENG */
#ifndef _CF_TIMER_H_
#define _CF_TIMER_H_
#include <time.h>
#include <sys/time.h>
#include "cf_list.h"

typedef struct cf_timer{
    struct timeval start_clock;
    struct timeval expires;
    void* data;
    void(*function)(void* data);
    CFListHead list;
}CFTimer;

int cf_timers_init();
int cf_timer_add(struct timeval* expires, void(*function)(void* data), void* data);
int cf_timers_trigger();  /* this function must be called cyclly */
int cf_timers_clean();
#endif
